<?php

namespace app\api\controller\v1;

use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use app\common\exception\MissException;

class Banner extends Base
{
    /**
     * $id
     * /api/v1/banner/:id
     */
    public function getBannerByID($id)
    {
        (new IDMustBePositiveInt())->goCheck();
        $banner = BannerModel::getOne($id);
        if (empty($banner)) {
            throw new MissException([
                'msg' => 'banner没找到'
            ]);
        }
//        return $banner;
//        return json($banner)->send();

//        $res = new SuccessMessage($banner);
//        return json($res, $res->code)->send();
        $this->ok($banner);
    }
}